<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<jsp:useBean id="utilities" class="masterpiece.util.Utilities" scope="session" />    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Delete Picture</title>
<link rel="stylesheet" type="text/css" href="css/default.css" />
</head>
<body>
<%@ include file="top_menu.jsp" %>
  <form action="deletePic.jsp" method="get">
  <h1>Delete Picture</h1>
  <%
  String picIDParam = request.getParameter("picID");
  if (picIDParam == null)
	  picIDParam = "";
  %>
  
    <dl>
      <dt>Picture ID to delete:</dt>
      <dd><input type="text" name="picID" value="<%=picIDParam%>" /></dd>
    </dl>
    <p class="buttons">
    <input type="submit" value="Delete" />
    </p>
  </form>
  
  <%
  boolean wasDel = false;
  try {
	  int pictureID = -1;
	  if (request.getParameter("picID") != null)
	    pictureID = Integer.parseInt(request.getParameter("picID"));
    if (pictureID != -1) {
	   try {
    	  utilities.deletePicture(pictureID);
     	  wasDel = true;
  	  } catch (Exception e) {
      	  out.print("<p class=\"message error\">Error deleting picture: "+e.getMessage()+"</p>");
  	  }
	 %>
  
  <table>
    <thead>
      <tr>
        <td>ID #</td>
        <td>Status</td>
      </tr>
    </thead>
    <tbody>
      <tr>
      	<td><%=pictureID%></td>
        <%if(wasDel){%>
        <td>deleted</td>
        <%}else{%>
        <td>available</td>
        <%}%>
      </tr>
    </tbody>
  </table>
  
  <%
    }
  } catch (NumberFormatException numE) {
	  out.print("<p class=\"message error\">NumberFormatException: "+numE.getMessage()+"</p>");
  } %>

</body>
</html>